<template>
  <a-modal
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel"
    cancelText="关闭"
  >
    <a-descriptions :title="formInfo.title">
      <a-descriptions-item label="用户类型">{{ this.$sysDictFilter(formInfo.userFlag, 'userFlag') }}</a-descriptions-item>
      <a-descriptions-item label="创建时间">{{ formInfo.createTime }}</a-descriptions-item>
      <a-descriptions-item label="是否已读">{{ this.$sysDictFilter(formInfo.readFlag, 'readFlag') }}</a-descriptions-item>
      <a-descriptions-item label="反馈意见">
        <div v-html="formInfo.content"></div>
      </a-descriptions-item>
    </a-descriptions>
  </a-modal>
</template>

<script>
  import pick from 'lodash.pick'
  import { getAction } from '@/api/manage'

  export default {
    name: 'SysFeedbackView',
    components: {},
    data () {
      return {
        visible: false,
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 }
        },
        confirmLoading: false,
        formInfo: {},
        url: {
          saveInfo: '/system/sysFeedback/save',
          getInfo: '/system/sysFeedback/info'
        }
      }
    },
    created () {
    },
    methods: {
      show (record) {
        this.$objToOverride(this.formInfo, record)
        if (this.formInfo.id) {
          getAction(this.url.getInfo, { 'id': record.id }).then(res => {
            this.$nextTick(() => {
              this.formInfo = (pick(res.result.data
                , 'id'
                , 'userFlag'
                , 'content'
                , 'createTime'
                , 'readFlag'
              ))
            })
          })
        }
        this.visible = true
      },
      // 确定
      handleSubmit () {
        this.visible = false
      },
      // 关闭
      handleCancel () {
        this.close()
      },
      close () {
        this.visible = false
      }
    }
  }
</script>
